package com.softservecom.training.shop.pojos;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Users entity.
 * 
 * @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "Users", schema = "dbo", catalog = "Java")
public class Users implements java.io.Serializable {

	// Fields

	private Integer userId;
	private UsersTypes usersTypes;
	private UsersDetails usersDetails;
	private String login;
	private String password;
	private Set<Orders> orderses = new HashSet<Orders>(0);
	private Set<Products> productses = new HashSet<Products>(0);

	// Constructors

	/** default constructor */
	public Users() {
	}

	/** minimal constructor */
	public Users(Integer userId, UsersTypes usersTypes,
			UsersDetails usersDetails, String login, String password) {
		this.userId = userId;
		this.usersTypes = usersTypes;
		this.usersDetails = usersDetails;
		this.login = login;
		this.password = password;
	}

	/** full constructor */
	public Users(Integer userId, UsersTypes usersTypes,
			UsersDetails usersDetails, String login, String password,
			Set<Orders> orderses, Set<Products> productses) {
		this.userId = userId;
		this.usersTypes = usersTypes;
		this.usersDetails = usersDetails;
		this.login = login;
		this.password = password;
		this.orderses = orderses;
		this.productses = productses;
	}

	// Property accessors
	@Id
	@Column(name = "UserID", unique = true, nullable = false)
	public Integer getUserId() {
		return this.userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "UserTypeID", nullable = false)
	public UsersTypes getUsersTypes() {
		return this.usersTypes;
	}

	public void setUsersTypes(UsersTypes usersTypes) {
		this.usersTypes = usersTypes;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "UserDetailsID", nullable = false)
	public UsersDetails getUsersDetails() {
		return this.usersDetails;
	}

	public void setUsersDetails(UsersDetails usersDetails) {
		this.usersDetails = usersDetails;
	}

	@Column(name = "Login", nullable = false, length = 50)
	public String getLogin() {
		return this.login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	@Column(name = "Password", nullable = false, length = 50)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "users")
	public Set<Orders> getOrderses() {
		return this.orderses;
	}

	public void setOrderses(Set<Orders> orderses) {
		this.orderses = orderses;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "users")
	public Set<Products> getProductses() {
		return this.productses;
	}

	public void setProductses(Set<Products> productses) {
		this.productses = productses;
	}

}